﻿using ApplicationModels.A05.Reports;
using ApplicationService;
using Commons.Requests;
using Commons.Responses;
using EntityModels.E05.Reports;
using IApplicationServices;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers
{
    [Route("[controller]/[action]")]
    public class ReportTypeController : BaseController<int, ReportType, ReportTypeAM>
    {
        private readonly IReportTypeService service;
        public ReportTypeController(IReportTypeService apiService) : base(apiService)
        {
            service = apiService;
        }

        [HttpGet]
        public async Task<DatasResponse<ReportTypeAM>> GetParentAsync()
        {
            return await ApiService.GetAllAsync(x => x.ParentId == 0);
        }

        public override async Task<DatasResponse<ReportTypeAM>> GetAsync()
        {
            return await service.GetAllAsync();
        }

        [HttpGet]
        public async Task<DatasResponse<ReportTypeAM>> GetByParentId(int id)
        {
            return await ApiService.GetAllAsync(x => x.ParentId == id);
        }


    }
}
